<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Admin extends CI_Controller {

	function __construct(){
		parent::__construct();
		/* простая авторизация */
		$this->load->model('auth_model');

		$this->load->helper('url');
		$this->load->database();
		$this->load->library('session');
	}

	public function index()
	{
		$data = array (
			'version' => '0.0.6'
		);
		$this->load->view('admin', $data);
	}

	public function pages ($cmd = '')
	{

		$this->load->model('pages_model');
		if ($cmd == '')
		{
			$data = array ();
			$data['pages_last_access'] = microtime(true);
			$this->load->view('admin/pages', $data);
		}
		elseif (method_exists($this->pages_model, $cmd))
		{
			$data = $this->pages_model->$cmd();
			print $data;

 		} else {
 			show_404();
 		}
	}

	public function templates ($cmd = '')
	{

		$this->load->model('templates_model');
		if ($cmd == '')
		{
			$data = array ();
			$data['templates_last_access'] = microtime(true);
			$this->load->view('admin/templates', $data);
		}
		elseif (method_exists($this->templates_model, $cmd))
		{
			$data = $this->templates_model->$cmd();
			print $data;

 		} else {
 			show_404();
 		}
	}


	public function tools ($act = '', $class = '', $func = 'admin')
	{
		$this->load->model('tools_model');
		switch ($act)
		{
			case '':
				$data = array ();
				$this->load->view('admin/tools', $data);
				break;
			case 'load_tools':
				$data = $this->tools_model->load_tools();
				print json_encode($data);
				break;
			case 'exec_tools':
				$data = $this->tools_model->exec_tools($class, $func);
				print $data;
				break;
			default:
				show_404();
		}

	}


}

/* End of file admin.php */
/* Location: ./application/controllers/Sample.php */
// Created 30.11.2011 17:40:14
// Last modification: 10.01.2012 13:19:13